package com.javaoopthree.master;

import com.javaoopthree.Cart;
import com.javaoopthree.Menus;
import com.javaoopthree.Order;

import java.util.Scanner;

public class MenusMaster {
    Scanner scanner = new Scanner(System.in);

    //餐袋中心
    Cart cart=new Cart();

    //订单中心
    Order[] order = new Order[10];

    //临时的存储点菜的数组
    Menus[] menuscart = new Menus[10];

    //点餐主分支
    public void toMenuMaster(Menus[] menus){
        boolean isOk=true;
        do {
            System.out.println("请选择需要的操作：");
            System.out.println("\t\t1：点餐，2：查看餐袋，3：付款，4：查看订单，5：返回菜单");
            int i = scanner.nextInt();
            switch (i){
                case 1:
                    //初始化菜品 todo
                    Menus menus1 = new Menus();
                    menus1.initMenu(menus);
                    //打印菜品
                    menus1.showMenus(menus);
                    //点菜
                    Rmenus(menus1,menus);

                    break;
                case 2:
                    Cart cart1 = new Cart();
                    cart1.showCartMenu(cart);
                    break;
                case 3:
                    //打印餐袋
                    Cart cart2 = new Cart();
                    cart2.showCartMenu(cart);
                    //选择支付方式：1：全部支付，2：部分支付
                    CartMaster cartMaster = new CartMaster();
                    cartMaster.toCartMaster(cart,order);
                    break;
                case 4:
                    //打印订单
                    Order order1 = new Order();
                    order1.showOrder(order);
                    break;
                default:
                    isOk=false;
                    break;
            }

        }while (isOk);
    }

    //控制循环点餐
    public void Rmenus(Menus menus1,Menus[] menus) {
        boolean b =true;
        do {
             b = menus1.addCart(cart, menuscart,menus);
        }while (b);

    }

}
